<?php
// html options string from associative array
function html_options($options='') {
  if(is_string($options)){return $options;};
  $final = "";
  foreach($options as $key=>$value) {
    $final .= "$key='$value'";
  }
  return $final;
}
// <select> element from array of items
function selector($items,$name,$selected=NULL,$options='') {
  echo "<select name='$name' ".html_options($options).">\n";
  foreach($items as $item) {
    if($item == $selected) {
      echo "<option value='$item' selected>$item</option>\n";
    } else {
      echo "<option value='$item'>$item</option>\n";
    }
  }
  echo "</select>\n";
}
?>